package utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class URLTools {
	
	/**********************************************************************************************
	 * Functions to get URL String data
	 **********************************************************************************************/
	public static String getURLString(Context context){
		//create server address from preferences.
		SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
		String port = sharedPrefs.getString("prefConnPortKey", "");
		String server = sharedPrefs.getString("prefServerKey", "");
		String path = sharedPrefs.getString("prefPathKey", "");
		final String strStart = server + ":" + port + path;
		//String port = "8181";
		//String server = "https://www.charteredtech.net";
		//String path = "/openBrewRF-1.0/webresources/com.openbrew.openbrewrf.";
		//final String strStart = server + ":" + port + path;
		return strStart;
	}
	
	public static String getUSERString(Context context){
		SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
		String serverUser = sharedPrefs.getString("prefServerUser", "");
		//String serverUser = "openBrewClient";
		return serverUser;
	}
	
	public static String getPASSString(Context context){
		SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
		String serverPass = sharedPrefs.getString("prefServerPass", "");
		//String serverPass = "0p3nBr3w.547";
		return serverPass;
	}
	
	public static double getTaxRate(Context context){
		SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
		double taxRate = Double.parseDouble(sharedPrefs.getString("prefTaxRateKey", "0"));
		return taxRate;
	}

}
